Skip to content

feat(hooks): turn a subagent call into a lich session through lich's /subagent veto - #108

Merged
omartelo merged 2 commits into
mainfrom
feat/subagent-hook
Nov 23, 2026
Merged

omartelo merged 2 commits into
mainfrom
feat/subagent-hook

Conversation

@omartelo

Copy link
Copy Markdown
Collaborator

The plugin side of lich's subagent-cards contract (docs/hooks/subagent-cards.md in lich, merged at d33b02a8), and the first cut of the Claude Code mod's removal that comes with it.

Before the agent's own subagent tool runs, the plugin asks lich at /subagent. lich opens the task as a card and answers deny; the client turns that into the harness's own veto with lich's reason untouched, so the native subagent never runs and the model reads why. Every failure to get an answer (no lich, no jq for the script, a refused connection, 10 seconds without one, a non-200, a body that is not a decision) lets the call run. The client writes no text of its own.

  • hooks/veto-subagent.sh <harness>: one script for Claude Code (Agent, and Cursor CLI's Task through the same install), Codex (spawn_agent; collaborationspawn_agent sent sealed; collaborationwait_agent as a wait), Antigravity (invoke_subagent), Kiro CLI (subagent, use_subagent with InvokeSubagents) and Crush (agent). Tasks are mapped per the contract's table. The token rides the Authorization: Bearer header, which lich's /subagent takes (tokenOf).
  • Registrations: hooks/hooks.json (matcher Agent|Task), hooks/codex-hooks.json (the three Codex tools; on Windows through the new hooks/win-veto.cmd, since win-run.cmd drops the stdout the veto rides), hooks/crush-hooks.json (^agent$), and Antigravity's hooks.json, where the veto is chained after the tool report in the one PreToolUse command so a call gets one verdict. Every entry gets 15 seconds, more than the 10 the hook waits. Kiro's are lich's to write (docs/subagent-cards.md, Registration lich writes).
  • opencode/lich.js (1.x, tool.execute.before, throws on deny) and omp/lich.js (tool_call, returns {block: true, reason}) do the same in process. opencode 2 is left out: its tool is subagent, and the contract has no row for it.
  • Retired, per the contract: the mod's agent-cards (hooks/agent-cards.js) and worker answer (hooks/worker-answer.js, /mod/answer), the prompt texts only they used, the footer's worker count, their docs and tests, and the vendored mod-answer.jsonl.
  • tests/fixtures/subagent-cards.jsonl is read at lich d33b02a8, which no release ships yet, the way refresh-fixtures.sh already pins mod-commands.

What is not measured is listed in docs/subagent-cards.md: tool_use_id outside Claude Code, Kiro's payload envelope and its use_subagent shape, how omp's context joins a prompt, Cursor CLI's payload, and win-veto.cmd on Windows. Each one fails to an allow or an empty field when it is wrong. A Codex user has to trust the changed hooks again with /hooks, or Codex skips them silently.

Version spots stay at 0.22.0, the release this whole feature ships as; the CHANGELOG's [Unreleased] entry is rewritten into the net change.

Test plan

  • node --test tests/*.test.mjs: 499 pass, including tests/subagent.test.mjs: every harness's body for its own call, every fixture answer replayed through each harness's veto (plus a non-ASCII reason with a newline), and the fail-open cases including a lich that never answers.
  • claude plugin test .: 20 pass.
  • claude plugin validate .claude-plugin/plugin.json and agy plugin validate .: pass with the warnings they had before.
  • tests/refresh-fixtures.sh leaves no diff.

…/subagent veto

Every harness but opencode 2 asks lich before its own subagent tool runs and
turns lich's deny into the harness's own veto, with lich's reason untouched;
every failure to get an answer within 10 seconds lets the native subagent run.
hooks/veto-subagent.sh serves Claude Code (and Cursor CLI), Codex, Antigravity,
Kiro CLI and Crush, and the opencode and omp modules do the same in process.

The Claude Code mod's agent-cards and worker answer are retired with it, along
with their prompt texts, docs and the footer's worker count. The
subagent-cards fixture is read at lich d33b02a8, in no release yet.
@omartelo
omartelo merged commit e724313 into main Nov 23, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant